package com.aiti.lulian.service.impl;

import com.aiti.base.core.base.service.iml.BaseSerivceImpl;
import com.aiti.lulian.entity.message.SignUpMessage;
import com.aiti.lulian.mapper.SignUpMessageMapper;
import com.aiti.lulian.service.ISignUpMessageService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author WongMz
 * @CreateDate 2024-08-07
 */
@Service
public class SignUpMessageServiceImpl extends BaseSerivceImpl<SignUpMessageMapper, SignUpMessage> implements ISignUpMessageService {

    @Autowired
    private ISignUpMessageService signUpMessageService;

    @Override
    public Map<String, Object> querySignUpMessage(String userId) {
        Map<String, Object> map = new HashMap<>();

        LambdaQueryWrapper<SignUpMessage> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SignUpMessage::getSupplierInquiryOrderUserId, userId);
        wrapper.eq(SignUpMessage::getIsRead, "0");
        wrapper.orderByDesc(SignUpMessage::getBaseCreateTime);
        List<SignUpMessage> list = signUpMessageService.list(wrapper);

        map.put("total", list.size());
        map.put("list", list);

        return map;
    }
}